<%@ Control Language="VB" AutoEventWireup="false" CodeFile="CustomDropDownBubble.ascx.vb"
    Inherits="UserCuntrols_CustomDropDownBubble" %>
    <asp:PlaceHolder ID="plcMain" runat="server">
        <asp:TextBox ID="txtDropdown" runat="server" CssClass="dropdownText" Width="150" Text="--Select--">
        </asp:TextBox><asp:HyperLink ID="tx" Style="margin-left: -2px;" runat="server" CssClass="dropdownarrowbubble" href="#" onmouseover="OpenCategory();"><asp:Image ID="imgDropdown" runat="server" ImageUrl="~/images/btnDropdown.png" Height="30" ImageAlign="absMiddle" Width="23" /></asp:HyperLink>
        <asp:HiddenField ID="hidDropdown" runat="server" />
        <iframe id="ifCategory" style="display:none"></iframe>
    </asp:PlaceHolder>
<asp:Panel ID="tx_div" runat="server" CssClass="dropdown" Style="visibility: hidden;
    left: 447px; top: 114px;height:290px;width:500px;">
    <div id="divMain">
        <div align="left" style="float:left;width:60px;"><asp:Literal ID="litBack" runat="server"></asp:Literal></div>
        <div style="float:right;width:100px;" align="center"><asp:Literal ID="litBackMain" runat="server"></asp:Literal></div>
        <div align="center">
            <strong>
                <asp:Literal ID="litHeading" runat="server"></asp:Literal></strong>
        </div>
        <div>
            <asp:DataList ID="dlSubCategory" runat="server" RepeatColumns="4" RepeatDirection="Horizontal"
                CellSpacing="5" HorizontalAlign="Left">
                <ItemTemplate>
                    <a id="<%#Eval("CategoryID")%>" href="<%#Eval("Href")%>" onclick="OpenSubCategory(this,'<%=Request("ParentID")%>');"
                        target="<%#Eval("Target")%>" title="<%#Eval("Text")%>">
                        <%#PopulateImage(Eval("Image")) %><%#Eval("Text")%></a>
                </ItemTemplate>
            </asp:DataList>
            <div align="center">
                <asp:Literal ID="litMessage" runat="server"></asp:Literal></div>
        </div>
    </div>
    <script language="javascript">
    var oLocation;
    var oCatParentID = new Array();
    trim = function(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }

    ltrim =function(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }

    rtrim = function(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }

    Closecategory = function(){
    oLocation = '<%=tx_div.ClientID %>'
    $(oLocation).innerHTML = "";
    }
    OpenCategory = function(){
            var pars = "ParentID=Root"
            oCatParentID = new Array();
            oLocation = '<%=tx_div.ClientID %>'
            var url = "<%= ResolveUrl("~/Category.aspx")%>?XML=<%=DataXML %>&Container="+oLocation+"&"+pars;
            $(oLocation).innerHTML = '<div id="loader" style="padding-top:30px;" align="center"><img src="<%=ResolveUrl("~/images/loading-spinner.gif") %>" alt="Loading..." /><span id="loaderText">Loading...</span></div>';
    						
            $('ifCategory').src = url;
        };
    OpenSubCategory = function(oBj,PaID){
        var pars = "SubMenu=1&ParentID="+oBj.id;
        
        oCatParentID[oCatParentID.length]=PaID;
        
        var url = "<%= ResolveUrl("~/Category.aspx")%>?XML=<%=DataXML %>&Container="+oLocation+"&"+pars;
        $(oLocation).innerHTML = '<div id="loader" style="padding-top:30px;" align="center"><img src="<%=ResolveUrl("~/images/loading-spinner.gif") %>" alt="Loading..." /><span id="loaderText">Loading...</span></div>';
        $('ifHid').src = url;
        $('<%=txtDropdown.ClientID %>').value = oBj.textContent?oBj.textContent:oBj.title;
        $('<%=txtDropdown.ClientID %>').value = trim($('<%=txtDropdown.ClientID %>').value,' ');
        $('<%=hidDropdown.ClientID %>').value = oBj.id;
        
    };
    BackCategory = function(){
        oPaID = oCatParentID[oCatParentID.length - 1];
        oCatParentID.length = oCatParentID.length - 1;
        var pars;
        if(oCatParentID.length > 0)
            pars = "SubMenu=1&ParentID="+oPaID;
        else
            pars = "ParentID="+oPaID;         
        
        var url = "<%= ResolveUrl("~/Category.aspx")%>?XML=<%=DataXML %>&Container="+oLocation+"&"+pars;
        $(oLocation).innerHTML = '<div id="loader" style="padding-top:30px;" align="center"><img src="<%=ResolveUrl("~/images/loading-spinner.gif") %>" alt="Loading..." /><span id="loaderText">Loading...</span></div>';
        $('ifHid').src = url;
    };
    BackMainCategory = function(){
        OpenCategory();
    };
    PopulateParent = function(){
        try{
            window.parent.document.getElementById('<%=Request("Container") %>').innerHTML = document.getElementById('<%=tx_div.ClientID %>').innerHTML;
            }catch(e){}
        };
    PopulateParent();
    </script>
</asp:Panel>
